package com.feidee.fd.sml.algorithm.feature

import com.feidee.fd.sml.algorithm.component.feature.{DCTEncoder, DCTEncoderParam}
import com.feidee.fd.sml.algorithm.util.{TestingDataGenerator, ToolClass}
import org.scalatest.FunSuite

/**
  * @Author songhaicheng
  * @Date 2019/3/26 13:45
  * @Description
  * @Reviewer
  */
class DCTEncoderSuite extends FunSuite {
  val paramStr: String =
    """
      |{
      |	"inputCol": "features",
      |	"outputCol": "featuresDCT",
      |	"preserveCols": "label,features",
      | "inverse": true
      |}
    """.stripMargin

  val dct = new DCTEncoder
  val param: DCTEncoderParam = dct.parseParam(new ToolClass().encrypt(paramStr))

  test("dct parameter") {
    assert("features".equals(param.inputCol) && "featuresDCT".equals(param.outputCol) &&
      "label,features".equals(param.preserveCols) && param.inverse)
  }

  test("dct transformation") {
    val data = TestingDataGenerator.sampleLibsvmData
    val res = dct.train(param, data).transform(data)
    assert(res.schema.size == 3)
  }

}
